<template>
    <el-container style="height: 500px; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu :default-openeds="['1', '3']">
            <el-submenu index="1" @click.native="admin()">
                <template slot="title"><i class="el-icon-setting" ></i>订单</template>
            <el-menu-item-group>
              <template slot="title" >Index</template>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-menu"></i>详情</template>
            <el-menu-item-group>
              <template slot="title">详情</template>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3" @click.native="user()">
            <template slot="title"><i class="el-icon-setting" ></i>人员管理</template>
            <el-menu-item-group>
              <template slot="title">人员详情</template>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      
      <el-container>
        <el-header style="text-align: right; font-size: 12px">
          <el-dropdown>
            <i class="el-icon-setting" style="margin-right: 15px"></i>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>查看</el-dropdown-item>
              <el-dropdown-item>新增</el-dropdown-item>
              <el-dropdown-item>删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <span>YY</span>
        </el-header>
        
        <el-main>
          <el-table :data="tableData">
            <el-table-column prop="people" label="用户" width="140">
            </el-table-column>
            <el-table-column prop="name" label="账号" width="120">
            </el-table-column>
            <el-table-column prop="pin" label="密码">
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">  
          <el-button  
            size="mini"  
            @click="handleEdit(scope.row)">编辑</el-button>  
          <el-button  
            size="mini"  
            type="danger"  
            @click="handleDelete(scope.row)">删除</el-button>  
        </template>  
            </el-table-column>
          </el-table>
  
          <el-dialog  
      title="编辑数据"  
      :visible.sync="dialogVisible"  
      width="30%"  
      @close="dialogVisible = false">  
      <el-form :model="editForm" label-width="80px">  
        <el-form-item label="用户">  
          <el-input v-model="editForm.people"></el-input>  
        </el-form-item>  
        <el-form-item label="账号">  
          <el-input v-model="editForm.name"></el-input>  
        </el-form-item>  
        <el-form-item label="密码">  
          <el-input v-model="editForm.pin"></el-input>  
        </el-form-item>
        <el-form-item>  
          <el-button type="primary" @click="handleEditSubmit">确定</el-button>  
          <el-button @click="dialogVisible = false">取消</el-button>  
        </el-form-item>  
      </el-form>  
    </el-dialog>  
        </el-main>
      </el-container>
    </el-container>
    
  </template>
    
  <style>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  
  .el-aside {
    color: #333;
  }
  </style>
  
  <script>
    export default {
      data() {
        return {
          tableData: [{
            people:'me',
            name:'admin',
            pin:'123456'
          }, {
            people:'you',
            name:'admin1',
            pin:'123456'
          }, {
            people:'AAAA',
            name:'clarence',
            pin:'001017'
          }, {
            people:'BBBB',
            name:'windy',
            pin:'000805'
          }, {
            people:'he',
            name:'admin3',
            pin:'123456'
          }, {
            people:'she',
            name:'admin4',
            pin:'123456'
          }],
          dialogVisible: false, 
          editRow: null, 
          editForm: { 
            people:'',
            name:'',
            pin:''
        },  
        }
      },
      methods: {  
        handleEdit(row) {  
          this.dialogVisible = true;  
          this.editRow = row;  
          this.editForm.people = row.people;  
          this.editForm.name = row.name;  
          this.editForm.pin = row.pin; 
          
        },  
        handleEditSubmit() {   
          console.log('编辑的数据：', this.editForm);    
          this.editRow.people = this.editForm.people;  
          this.editRow.name = this.editForm.name;  
          this.editRow.pin = this.editForm.pin; 
          this.dialogVisible = false; 
        },  
        handleDelete(row) {  
          console.log('删除', row);  
          this.tableData = this.tableData.filter(item => item !== row);  
        } ,
        admin(){
        this.$router.push('/admin')
      },
      }  
    }
  </script>